package com.dh.inner;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class InnerClass06 {
    public static void main(String[] args) {
        MyMath myMath = new MyMath();
//        Icompute icompute = new M();
//        myMath.math(icompute, 1, 2);
//        myMath.math(new M(), 1, 2);
        int result = myMath.math(new Icompute() {// 创建的接口实现类，只不过这个类没有名字而已
            @Override
            public int calc(int a, int b) {
                return a + b;
            }
        }, 1, 2);
        System.out.println(result);

        // GUI---java图形化编程
    }
}


interface Icompute {
    int calc(int a, int b);
}

//class M implements Icompute {
//
//    @Override
//    public int calc(int a, int b) {
//        return a + b;
//    }
//}

class MyMath {
    public int math(Icompute icompute, int a, int b) {
        return icompute.calc(a, b);
    }
}
